package model.service;

import model.Coordinate;
import model.location.WorldCoordinate;

import com.google.zxing.Result;

public class ServiceRefPoint 
{
	
	private Result _result;
	
	public ServiceRefPoint(Result result)
	{
		this._result = result;
	}
	
	public Coordinate getScreenCoordinate()
	{
		int width = (int) (_result.getResultPoints()[2].getX() - _result.getResultPoints()[1].getX());
		int height = (int) (_result.getResultPoints()[0].getY() - _result.getResultPoints()[1].getY());
		
		int x = (int) (_result.getResultPoints()[1].getX() + (width / 2));
		int y = (int) (_result.getResultPoints()[1].getY() + (height / 2));
		
		return new Coordinate(x,y);
	}
	
	public int getHeight()
	{
		return (int) (_result.getResultPoints()[0].getY() - _result.getResultPoints()[1].getY());
	}
	
	public WorldCoordinate getWorldCoordinate()
	{
		String[] values = _result.getText().split("_");
		WorldCoordinate _coord = new WorldCoordinate(Integer.parseInt(values[0]), 
						Integer.parseInt(values[1]), Integer.parseInt(values[2]));
		return _coord;
	}

}
